<template>
  <div class="workContainer">
    <div class="handle-box" style="text-align: center;margin-top: -15px;margin-left:40px">
      <!--      方法一-->
<!--      <div class="all">-->
<!--        <el-upload class="upload-demo"-->
<!--                   name="upfile"-->
<!--                   drag-->
<!--                   action=""-->
<!--                   :before-upload="beforeUpload"-->
<!--                   :on-success="onSuccess"-->
<!--                   :on-error="onError"-->
<!--                   multiple-->
<!--                   ref="newupload"-->
<!--                   :auto-upload="false"-->
<!--        >-->
<!--          <i class="el-icon-upload"></i>-->
<!--          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em>     </div>-->
<!--          &lt;!&ndash; <div class="el-upload__tip" slot="tip">请注意您只能上传.mp4 .flv .mov格式的视频文件</div> &ndash;&gt;-->
<!--        </el-upload>-->
<!--        <el-button type="primary" @click="newSubmitForm()" class="yes-btn">上传</el-button>-->
        <!-- <el-button @click="resetForm('newform')">
          重 置
        </el-button> -->
<!--      </div>-->

<!--      方法2-->
<!--      <div>-->
<!--        <form action="" enctype="multipart/form-data" id="upload">-->
<!--          <input type="file" name="file" />-->
<!--          <el-button-->
<!--              @click="Submit()"-->
<!--              type="success"-->
<!--              size="mini"-->
<!--              icon="el-icon-upload2"-->
<!--          >上传文件</el-button-->
<!--          >-->
<!--        </form>-->
<!--      </div>-->
<!--      <el-upload class="upload-demo"-->
<!--                 name="upfile"-->
<!--                 drag-->
<!--                 action="http://localhost:8081/api/v1/user/abstract_dggd3/2"-->
<!--                 :before-upload="beforeUpload"-->
<!--                 ref="newupload"-->
<!--                 :auto-upload="false"-->
<!--                 :headers="importHeaders"-->

<!--      >-->
<!--        <i class="el-icon-upload"></i>-->
<!--        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em>     </div>-->
<!--        &lt;!&ndash; <div class="el-upload__tip" slot="tip">请注意您只能上传.mp4 .flv .mov格式的视频文件</div> &ndash;&gt;-->
<!--      </el-upload>-->
      <el-input placeholder="请输入工单编号" v-model="inputNum" clearable size="mini" style="width: 150px;margin-right: 20px"></el-input>
      <el-button type="primary" icon="el-icon-edit" @click="addWork" size="mini">导入工单</el-button>
      <el-button type="primary" icon="el-icon-edit" @click="check" size="mini">检查</el-button>
      <el-button type="primary" icon="el-icon-success" @click="push" size="mini">提交</el-button>
    </div>
    <el-form class="selectForm" ref="formData" :model="formData" :rules="rules"
             size="mini" label-width="150px" style="margin-top: 20px"
             v-loading="loading" element-loading-text="正在提交检查……"
             element-loading-spinner="el-icon-loading" element-loading-background="rgba(238,241,246,0.8)">
      <el-row style="margin-top: -20px" class="el-row1">
        <el-col :span="8">
          <el-form-item label="接单人员：" prop="name">
            <el-input v-model="formData.name" show-word-limit :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="接单部门：" prop="department">
            <el-input v-model="formData.department" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="受理时间：" prop="processTime">
            <el-input v-model="formData.processTime" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="start" align="top" style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="一级分类：" prop="kind1">
            <el-input v-model="formData.kind1" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="二级分类：" prop="kind2">
            <el-input v-model="formData.kind2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <p class="timeRemind" v-show="errorTimeVisible">{{timeRemind}}</p>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label-width="0" prop="selects" style="margin-left: 60px">
            <el-radio v-model="formData.selects" label="重大事件" style="margin-left: 10px">重大事件</el-radio>
            <el-radio v-model="formData.selects" label="敏感工单" style="margin-left: 20px">敏感工单</el-radio>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="120px" label="是否约时工单：" prop="ifAppoint" style="margin-left: 30px">
            <el-input v-model="formData.ifAppoint" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="95px" label="约时时间：" prop="appointTime" style="margin-left: 55px">
            <el-input v-model="formData.appointTime" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="处理结果：" prop="result">
            <el-input v-model="formData.result" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -15px">
        <el-col :span="24">
          <el-form-item label="客户意见：" prop="clientSuggestion" class="client">
            <el-input v-model="formData.clientSuggestion" type="textarea" :autosize="{minRows: 1, maxRows: 2}" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -15px">
        <el-col :span="24">
          <el-form-item label="承办意见：" prop="takeSuggestion">
            <el-input v-model="formData.takeSuggestion" type="textarea" :autosize="{minRows: 1, maxRows: 2}"
                      :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
      </el-row >
      <el-row style="margin-top: -15px">
        <el-col :span="24">
          <el-form-item label="常用意见：" prop="commonSuggestion">
            <el-cascader :options="commonOptions" :props="{ expandTrigger: 'hover' }" v-model="formData.commonSuggestion" style="width: 70%">
              <template #default="{ node, data }">
                <span>{{ data.label }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -15px">
        <el-col :span="24">
          <el-form-item label="处理情况：" prop="handleInformation" class="process">
            <div class="but2">
              <el-row><el-button type="primary" icon="el-icon-edit" @click="edit()" size="mini" class="butS">编辑</el-button></el-row>
              <el-row><el-button type="primary" icon="el-icon-success" @click="save()" size="mini" class="butS">保存</el-button></el-row>
            </div>
            <div class="el-textarea el-input&#45;&#45;mini ">
              <textarea id="editText" class="el-textarea__inner "  v-model="formData.handleInformation" autocomplete="off"  style="min-height: 30px; height: 30px;"></textarea>
<!--              栗明改的-->
              <label id="saveLabel" style="height: 200px;"></label>
            </div>
          </el-form-item>
<!--          <p class="processRemind"> {{this.processRemind}}</p>-->
<!--          栗明改的-->
          <p class="processRemind" v-html="this.processRemind"></p>
        </el-col>
      </el-row >
      <el-row style="margin-top: 12px">
        <el-col :span="8">
          <el-form-item label-width="150px" label="客户诉求一级分类：" prop="client1">
            <el-input v-model="formData.client1" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="150px" label="客户诉求二级分类：" prop="client2">
            <el-input v-model="formData.client2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="150px" label="客户诉求三级分类：" prop="client3">
            <el-input v-model="formData.client3" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="所属县区：" prop="country">
            <el-input v-model="formData.country" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="供电所：" prop="powerSupply">
            <el-select v-model="formData.powerSupply" :style="{width: '100%'}">
              <el-option v-for="(item, index) in powerOptions" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户编号1：" prop="number">
            <el-input v-model="formData.number" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="城农网标志：" prop="logo">
            <el-input v-model="formData.logo" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="是否最终答复：" prop="answer">
            <el-select v-model="formData.answer" placeholder="请选择是否最终答复：" :style="{width: '100%'}">
              <el-option v-for="(item, index) in answerOptions" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -15px">
        <el-col :span="24">
          <el-form-item label="最终答复内容：" prop="answerContent" class="answerContent">
            <el-input v-model="formData.answerContent" type="textarea" :autosize="{minRows: 1, maxRows: 2}"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <div style="margin-top: -10px;margin-left: 50px">
        <el-table :data="tableData" height="50" border style="width: 100%" class="serverTable">
          <el-table-column prop="num" label="客户编号" width="180" align="center"/>
          <el-table-column prop="name" label="客户名称" width="180" align="center"/>
          <el-table-column prop="tel1" label="联系电话" width="180" align="center"/>
          <el-table-column prop="tel2" label="联系电话2" width="180" align="center"/>
          <el-table-column prop="tel3" label="联系电话3" width="180" align="center"/>
          <el-table-column prop="address" label="地址" align="center"/>
        </el-table>
      </div>
    </el-form>
    <!--    </el-col>-->
    <!--    </el-row>-->
  </div>
</template>
<script>
import {checkServer, fetchTable, fetchTableFile, pushServer, templateKind} from "../../api/api";
import {dateToUnix, getDateForm} from "../../utils/validate";
import axios from 'axios'
// import {token} from '../utils/request';
import XLSX from 'xlsx'
axios.defaults.withCredentials=true
axios.defaults.crossDomain=true

export default {
  components: {},
  props: [],
  data() {
    return {
      source: null,
      fileName: "",
      percent: 0,
      originalName: "",
      uploadState: false,
      filePath: "",
      complete: false,
      // editForm: {
      //   file: {},
      //   fileList: [],
      // },
      // gdnum1: '2',
      // gdnum2: '210407777981'
      processVisible: false,
      loading: false,
      errorTimeVisible: false,
      processRemind: '',
      sheetId:'',
      timeRemind: '受理时间提示',
      wrongStr: '经过',
      inputNum:'',
      tableData: [],
      commonOptions:[],//常用意见的级联下拉框
      kind1Arr: [],//存储所有一级分类数据
      kind1children: [],//存储所有一级分类下的二级分类数据
      kind1Options: [],// 存储所有一级分类的下拉框数据
      kindOptions:[],// 存储所有类别信息
      formData: {
        file:"",
        name: "",
        department: '',
        processTime: '',
        kind1: "",
        kind2: "",
        selects: '',
        ifAppoint: "",
        appointTime: "",
        result: '',
        clientSuggestion: '',
        takeSuggestion: '',
        commonSuggestion: '',
        handleInformation: '',
        client1: '',
        client2: '',
        client3: '',
        country: '',
        powerSupply: '',
        number: '',
        logo: '',
        answer: 1,
        answerContent: '',
      },
      rules: {
        name: [{required: true, message: '', trigger: 'change'}],
        department: [{required: true, message: '', trigger: 'change'}],
        processTime: [{required: true, message: '受理时间非空', trigger: 'change'}],
        kind1: [{required: true, message: '', trigger: 'change'}],
        kind2: [{required: true, message: '', trigger: 'change'}],
        handleInformation: [{required: true, message: '处理情况非空', trigger: 'change'}],
      },
      powerOptions:[{"label": "湘湖供电所", "value": 1}, {"label": "临浦供电所", "value": 2},
                    {"label": "瓜沥供电所", "value": 3}, {"label": "钱江供电所", "value": 4}],
      answerOptions: [{"label": "是", "value": 1}, {"label": "否", "value": 2}],
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getKindMsg()
  },
  mounted() {},
  methods: {
    beforeUpload(file){
      console.log(file)

      // axios({
      //     url: "http://localhost:8081/api/v1/user/abstract_dggd3/2",
      //     // url: "/v1/user/abstract_dggd3/2",
      //     method: "POST",
      //     headers: {
      //       // 'Content-Type': 'application/json;;charset=UTF-8',
      //       'Content-Type': 'multipart/form-data',
      //       changeOrigin: true, // 跨域
      //       access_token: localStorage.getItem("token"),
      //     },
      //     data: file,
      //     // data: formData,
      //   }).then((res)=>{
      //   if(res.data.status === 200)
      //           this.$message.success('导入工单成功！')
      //         else{
      //           this.$message.error('导入工单失败！')
      //         }
      // })
      fetchTableFile(2,file).then((res) => {
        console.log("file&&&&", file)
        console.log("res:&&&", res)
        if(res.data.status === 200)
          this.$message.success('导入工单成功！')
        else{
          this.$message.error('导入工单失败！')
        }
      })
    },
    // Submit() {
    //   var file_form = new window.FormData(upload);  //获取上传表单（文件）
    //   console.log("upload:", upload)
    //   // var formData = new window.FormData()
    //   // formData.append('dggdFile', document.querySelector('input[type=file]').files[0])
    //   console.log("获取上传表单（文件）:", file_form)
    //   fetchTableFile(2,file_form)
    //   // axios({
    //   //   url: "http://localhost:8081/api/v1/user/abstract_dggd3/2",
    //   //   // url: "/v1/user/abstract_dggd3/2",
    //   //   method: "POST",
    //   //   headers: {
    //   //     // 'Content-Type': 'application/json;;charset=UTF-8',
    //   //     'Content-Type': 'multipart/form-data',
    //   //     changeOrigin: true, // 跨域
    //   //     access_token: localStorage.getItem("token"),
    //   //   },
    //   //   data: file_form,
    //   //   // data: formData,
    //   // })
    //       .then((res) => {
    //         console.log("file_res", res.data)
    //         if (res.data.status === 200) {
    //           console.log("成功;", res.data.data)
    //         } else {
    //           console.log("失败；", res.data.msg)
    //         }
    //         console.log(res);
    //       })
    //       .catch((err) => {
    //         console.log(err);
    //       });
    // },

    // check按钮
    check() {
      console.log('this.form:', this.formData)
      console.log('this.tableData:', this.tableData)
      // 1.检查页面内容非空情况
      this.$refs.formData.validate(valid => {
        if (valid) {
          // if(this.file.name)
          if (this.inputNum) {
            this.loading = true
            this.processVisible = false
            this.processRemind = ''
            let param = {
              sdSubmitfwYsDggdId: this.sheetId,
              // sdSubmitfwNumber: this.file.name,
              sdSubmitfwNumber: this.inputNum,
              sdSubmitfwJdry: this.formData.name,
              sdSubmitfwJdbm: this.formData.department,
              sdSubmitfwSlsj: dateToUnix(this.formData.processTime),
              sdSubmitfwYjfl: this.formData.kind1,
              sdSubmitfwEjfl: this.formData.kind2,
              sdSubmitfwZdsjmggd: this.formData.selects,
              sdSubmitfwSfysgd: this.formData.ifAppoint,
              sdSubmitfwYssj: dateToUnix(this.formData.appointTime),
              sdSubmitfwCljg: this.formData.result,
              sdSubmitfwKhyj: this.formData.clientSuggestion,
              sdSubmitfwCyyj: this.formData.commonSuggestion,
              sdSubmitfwClqk: this.formData.handleInformation,
              sdSubmitfwKhsqyjfl: this.formData.client1,
              sdSubmitfwKhsqejfl: this.formData.client2,
              sdSubmitfwKhsqsjfl: this.formData.client3,
              sdSubmitfwSsqx: this.formData.country,
              sdSubmitfwGds: this.formData.powerSupply,
              sdSubmitfwSfzzdf: this.formData.answer,
              sdSubmitfwZzdfnr: this.formData.answerContent,
              sdSubmitfwKhmc: this.tableData[0].name,
              sdSubmitfwKhbh: this.tableData[0].num,
              sdSubmitfwKhdz: this.tableData[0].address,
              sdSubmitfwKhlxdh: this.tableData[0].tel1
            }
            console.log('param:', param)
            checkServer(param).then(res => {
              console.log('check的接口信息：', res.data)
              if (res.data.msg == '处理情况填写错误') {
                this.loading = false
                this.$notify({title: 'check完成', message: '请按照页面提示内容修改表单', type: 'warning'});
                console.log('res.data:', res.data)
                let remind = ''
                let index = 1
                let msg_content=''
                res.data.data.forEach(msg => {
                  console.log('msg=', msg)
                  // remind = remind +(index++) + '.' + msg
                  // 栗明改的
                  msg_content=(index++) + '.' + msg
                  msg_content=msg_content.replace(msg_content,msg_content+'<br/>')
                  remind= remind +msg_content
                  console.log('remind = ', remind)
                })
                this.processRemind = remind
                this.processVisible = true
              } else if (res.data.msg == '有错别字') {
                this.loading = false
                this.processRemind = '错别字修改建议：'+ res.data.data[0][0] + '-->' + res.data.data[0][1]
                for (let i = 1; i < res.data.data.length; i++){
                  this.processRemind += '，'+ res.data.data[i][0] + '-->' + res.data.data[i][1]
                }
                this.processVisible = true
                this.wrongStr = res.data.data[0][0]
                for (let i = 1; i < res.data.data.length; i++){
                  this.wrongStr += '，'+ res.data.data[i][0]
                }
                console.log('handleInformation:' + this.formData.handleInformation + 'wrongStr:' + this.wrongStr)
                this.$notify({title: '检查通过', message: 'check有错别字存在，已给出修改建议，可提交', type: 'success'});
                // this.setWordRed(this.formData.handleInformation, this.wrongStr)
              }
              if (res.data.status == 200) {
                this.loading = false
                this.processRemind = false
                this.processRemind = ''
                this.$notify({title: '检查通过', message: '页面已检查通过，可以提交！', type: 'success'})
              }
            })
          } else {
            this.$message.info('请输入工单编号')
            // this.$message.info('请选择文件')
          }
        }
      })
    },
    // 获取所有模板的类别信息
    getKindMsg() {
      this.commonOptions = []
      this.kind1Arr = []
      this.kindOptions = []
      templateKind().then((res) => {
        res.data.data.forEach((item) => {
          if (item.sdMblbYwlx == 2 && item.sdMblbEjflName != null) {
            let dict = {
              kind1: item.sdMblbYjflName,
              kind2: item.sdMblbEjflName
            }
            this.kindOptions.push(dict)
            this.kind1Arr.push(item.sdMblbYjflName)
          }
        })
        this.kind1Arr = [...new Set(this.kind1Arr)]
        this.kind1Arr.forEach((item) => {
          this.kind1children = []
          this.kindOptions.forEach((arr) => {
            if (item == arr.kind1) {
              let child = {
                value: arr.kind2,
                label: arr.kind2,
              }
              this.kind1children.push(child)
            }
          })
          let y = {
            value: item,
            label: item,
            children: this.kind1children
          }
          this.commonOptions.push(y)
        })
      })
    },
    // 获取接口数据
    addWork() {
      // console.log('this.inputNum', this.inputNum)
      console.log('this.inputNum', this.inputNum)
      if (this.inputNum) {
        fetchTable(2, this.inputNum).then((res) => {
          // fetchTable(2).then((res)=>{
          console.log('服务工单数据', res.data.data)
          if (res.data.status === 200) {
            this.$message.success('导入' + this.inputNum + '号工单成功！')
            this.sheetId = res.data.data.sdDggdId
            this.formData.name = res.data.data.sdDggdJdry
            this.formData.department = res.data.data.sdDggdJdbm
            console.log("后端受理时间：",res.data.data.sdDggdSlsj)
            console.log("前端转换后的受理时间：",getDateForm(res.data.data.sdDggdSlsj))
            this.formData.processTime = getDateForm(res.data.data.sdDggdSlsj)
            this.formData.kind1 = res.data.data.sdDggdYjflName
            this.formData.kind2 = res.data.data.sdDggdFwsqyjlx
            this.formData.clientSuggestion = res.data.data.sdDggdKhyj
            this.formData.handleInformation = res.data.data.sdDggdClqk
            this.formData.country = res.data.data.sdDggdSsqx
            this.formData.number = res.data.data.sdDggdKhbh
            this.processRemind = ''
            document.getElementById("editText").style.display = "none"
            document.getElementById("saveLabel").style.display = "block"
            document.getElementById("saveLabel").innerHTML = res.data.data.sdDggdClqk
            let labelContent = document.getElementById("saveLabel").innerHTML
            let end_index=labelContent.indexOf("处理结果")
            let str = labelContent.substring(labelContent.indexOf("处理经过") - 2, labelContent.indexOf("处理结果") - 2)
            // 栗明改的
            if (end_index>0) {
              labelContent = labelContent.replace(str, '<font color="red">' + str + '</font>')
            }
            document.getElementById("saveLabel").innerHTML = labelContent

            const table = {
              num: res.data.data.sdDggdKhbh,
              name: res.data.data.sdDggdKhmc,
              tel1: res.data.data.sdDggdKhlxdh,
              tel2: '',
              tel3: '',
              address: res.data.data.sdDggdKhdz
            };
            this.tableData.push(table)
          } else {
            this.$message.error('导入' + this.inputNum + '号工单失败！')
          }
        })
      } else {
        this.$message.info('未选择文件！')
      }
    },
    // 提交工单
    push() {
      console.log('this.form:', this.formData)
      console.log('this.tableData:', this.tableData)
      // 1.检查页面内容非空情况
      this.$refs.formData.validate(valid => {
        if (valid) {
          // if(this.file.name)
          if (this.inputNum) {
            this.loading = true
            this.processVisible = false
            this.processRemind = ''
            let param = {
              sdSubmitfwYsDggdId: this.sheetId,
              // sdSubmitfwNumber: this.file.name,
              sdSubmitfwNumber: this.inputNum,
              sdSubmitfwJdry: this.formData.name,
              sdSubmitfwJdbm: this.formData.department,
              sdSubmitfwSlsj: dateToUnix(this.formData.processTime),
              sdSubmitfwYjfl: this.formData.kind1,
              sdSubmitfwEjfl: this.formData.kind2,
              sdSubmitfwZdsjmggd: this.formData.selects,
              sdSubmitfwSfysgd: this.formData.ifAppoint,
              sdSubmitfwYssj: dateToUnix(this.formData.appointTime),
              sdSubmitfwCljg: this.formData.result,
              sdSubmitfwKhyj: this.formData.clientSuggestion,
              sdSubmitfwCyyj: this.formData.commonSuggestion,
              sdSubmitfwClqk: this.formData.handleInformation,
              sdSubmitfwKhsqyjfl: this.formData.client1,
              sdSubmitfwKhsqejfl: this.formData.client2,
              sdSubmitfwKhsqsjfl: this.formData.client3,
              sdSubmitfwSsqx: this.formData.country,
              sdSubmitfwGds: this.formData.powerSupply,
              sdSubmitfwSfzzdf: this.formData.answer,
              sdSubmitfwZzdfnr: this.formData.answerContent,
              sdSubmitfwKhmc: this.tableData[0].name,
              sdSubmitfwKhbh: this.tableData[0].num,
              sdSubmitfwKhdz: this.tableData[0].address,
              sdSubmitfwKhlxdh: this.tableData[0].tel1
            }
            console.log('param:', param)
            checkServer(param).then(res => {
              console.log('check的接口信息：', res.data)
              if (res.data.msg == '处理情况填写错误') {
                this.loading = false
                this.$notify({title: '提交失败', message: '请先进行检查', type: 'warning'});
                console.log('res.data:', res.data)
                let remind = ''
                let index = 1
                res.data.data.forEach(msg => {
                  console.log('msg=', msg)
                  remind = remind + (index++) + '.' + msg
                  console.log('remind = ', remind)
                })
                // this.processRemind = remind
                this.processVisible = true
              } else if(res.data.msg == '有错别字'){
                  this.loading = false
                  // this.processRemind = '错别字修改建议：'+ res.data.data[0][0] + '-->' + res.data.data[0][1]
                  // for (let i = 1; i < res.data.data.length; i++){
                  //   this.processRemind += '，'+ res.data.data[i][0] + '-->' + res.data.data[i][1]
                  // }
                  this.processVisible = true
                  this.wrongStr = res.data.data[0][0]
                  for (let i = 1; i < res.data.data.length; i++){
                    this.wrongStr += '，'+ res.data.data[i][0]
                  }
                  console.log('handleInformation:' + this.formData.handleInformation + 'wrongStr:' + this.wrongStr)
                  // this.$notify({title: '检查通过', message: 'check有错别字存在，已给出修改建议，可提交', type: 'success'});
                  // this.setWordRed(this.formData.handleInformation, this.wrongStr)
                  this.$confirm('还有错别字未修改, 是否继续提交?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                  }).then(() => {
                      pushServer(param).then(res => {
                        console.log('push接口数据：', res.data)
                        if (res.data.status == 200) {
                          this.$message.success('提交成功！')
                          const timer = setInterval(() => {
                            if(num < secounds) {
                              num++
                            }else {
                              clearInterval(timer)
                              alert('自定义函数在这里调用')
                            }
                          }, 1000)
                          // 提交成功后刷新界面
                          location.reload()

                          this.processVisible = false
                          // this.formData = {}
                          // this.processRemind=''
                          this.timeRemind = ''
                          // document.getElementById("saveLabel").innerHTML = ''
                        } else {
                          this.$message.error('提交失败！')
                        }
                      })
                  }).catch(() => {
                      this.loading = false
                      this.processRemind = '错别字修改建议：'+ res.data.data[0][0] + '-->' + res.data.data[0][1]
                      for (let i = 1; i < res.data.data.length; i++){
                        this.processRemind += '，'+ res.data.data[i][0] + '-->' + res.data.data[i][1]
                      }
                      this.processVisible = true
                      this.wrongStr = res.data.data[0][0]
                      for (let i = 1; i < res.data.data.length; i++){
                        this.wrongStr += '，'+ res.data.data[i][0]
                      }
                      console.log('handleInformation:' + this.formData.handleInformation + 'wrongStr:' + this.wrongStr)
                      this.$notify({title: '检查通过', message: 'check有错别字存在，已给出修改建议，可提交', type: 'success'});
                  });
                }else{
                  pushServer(param).then(res => {
                    console.log('push接口数据：', res.data)
                    if (res.data.status == 200) {
                      this.$message.success('提交成功！')
                      this.processVisible = false
                      // this.formData = {}
                      // this.processRemind=''
                      this.timeRemind = ''
                      // document.getElementById("saveLabel").innerHTML = ''
                    } else {
                      this.$message.error('提交失败！')
                    }
                  })
              }
            })
          } else {
            this.$message.info('请输入工单编号')
            // this.$message.info('请选择文件')
          }
        }
      })
    },

    edit() {
      document.getElementById("editText").style.display = "block"
      document.getElementById("saveLabel").style.display = "none"
    },
    save() {
      document.getElementById("editText").style.display = "none"
      document.getElementById("saveLabel").style.display = "block"
      document.getElementById("saveLabel").innerHTML = document.getElementById("editText").value
      let labelContent = document.getElementById("saveLabel").innerHTML
      //保存之后还需标红？？？
      // let str = labelContent.substring(labelContent.indexOf("处理经过") - 2, labelContent.indexOf("处理结果") - 2)
      // labelContent = labelContent.replace(str, '<font color="red">' + str + '</font>')
      document.getElementById("saveLabel").innerHTML = labelContent
      //点击保存按钮的同时将处理情况复制到剪切板
      var input = document.createElement("input");
      input.value = labelContent;
      document.body.appendChild(input);
      input.select();
      document.execCommand("Copy");
      this.$message.success('处理情况已复制到剪切板')
    },
  }
}

</script>
<style>
.timeRemind{
  color: red;
  font-size: 1px;
  margin-left: 150px;
}
.workContainer{
  /*padding: 20px 30px 12px 30px;*/
  /*margin-top: 10px;*/
  /*padding: 30px;*/
  padding: 20px 50px 12px 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
}
.serverTable tr,
.serverTable th {
  padding: 0;
  height: 25px;
}
.serverTable tr,
.serverTable td {
  padding: 0;
  height: 25px;
}
.serverTable tr,.serverTable td{
  font-size: 1px;
  text-align: center;
}
.selectForm .el-form-item__label{
  font-size: 1px;
}
.selectForm .el-radio__label{
  font-size: 1px;
}
.selectForm .el-select-dropdown__item{
  font-size: 1px;
}
.selectForm .el-input--mini .el-input__inner{
  height: 20px;
  line-height: 10px;
}
.client .el-textarea__inner{
  min-height: 15px !important;
  height: 20px !important;
}
.process .el-textarea__inner{
  /*栗明改的*/
  min-height: 200px !important;
  height: 200px !important;
  position: relative;
}
.answerContent .el-textarea__inner{
  min-height: 40px !important;
  height: 50px !important;
}
.processRemind{
  color: red;
  font-size: 1px;
  margin-left: 160px;
  margin-top: -15px;
  margin-bottom: 5px;
}
.but2{
  position: absolute;
  top: 20px;
  left: -74px;
}
.butS{
  padding: 4px 10px;
  min-height: 18px;
  margin-top: 3px;
}
#editText{
  display: none;
}

#saveLabel{
  height: 70px;
  width: 100%;
  box-sizing: border-box;
  padding: 5px 15px;
  border: 1px solid #DCDFE6;
  border-radius: 4px;
  display: block;
  font-size: inherit;
  line-height: 1.5;
  overflow: auto;
}
</style>
